#ifndef SYS_CONTROL_H
#define SYS_CONTROL_H

//#include <QDebug>
#include <QObject>

#include "img_file.h"
#include "img_viewer.h"

#include "dlg_setting.h"
#include "dlg_diskfile.h"
#include "dlg_message.h"

#include "anls_core.h"

#include <vtkWindowToImageFilter.h>
#include <vtkPNGWriter.h>

QT_BEGIN_NAMESPACE
namespace Ui
{
    class MainWindow;
}
QT_END_NAMESPACE

union DESCRIPT {//共用体，将推理结果转为char
    char str[80];
    float value[20];
};

class sys_Control: public QObject
{

    Q_OBJECT

    friend class MainWindow;

private:
    Ui::MainWindow * const ui;
    dlg_DiskFile * m_dlgDiskfile;
    img_File * m_imgFile;
    img_Viewer * m_imgViewer;
    anls_Core * m_anlsCore;
    anls_Data * m_anlsData{nullptr};
    dlg_Setting m_dlgSetting;
    dlg_Message m_dlgMessage;

    bool tabFlag{true}, modeFlag{true};

public:
    explicit sys_Control(Ui::MainWindow * _ui, QObject *parent = nullptr);
    ~sys_Control();
    void openDiskFile();
    void setImgFile(const QString &fileName);
    void show3DInfection();
    void showMessage();
    void setSetting();
    void openAnalysisFile();
    void analysisImg();
    void analysisDataFinish(anls_Data & _data);
    void showAnlsImg();
    void saveAnalysis();
    void saveWindowShot(vtkRenderWindow * _window);

    void setDangerUIClose();

public:
    img_Viewer* getImgViewer()const;

private:
    void setUI();
    void syneUI();
    void setPosition();
    void setCurrentPix();
    void initImgWidget();
    void initAnlsWidget();

signals:
    void fileOpened(const QString fileName);
};

#endif // SYS_CONTROL_H
